package com.zzw.zim.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzw.zim.common.utils.Result;
import com.zzw.zim.system.dto.AddSysMenuDTO;
import com.zzw.zim.system.dto.EditSysMenuDTO;
import com.zzw.zim.system.dto.QueryMenuPageDTO;
import com.zzw.zim.system.service.SysMenuService;
import com.zzw.zim.system.vo.SysMenuVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;


/**
 * 菜单管理
 *
 * @author XiaoJie
 * @date 2025-05-13 09:43:18
 */
@Tag(name = "系统权限菜单控制器")
@RestController
@RequestMapping("system/menu")
public class SysMenuController {

    @Resource
    private SysMenuService menuService;

    @PostMapping("add")
    @Operation(summary = "新增角色")
    public Result<String> addMenu (@RequestBody AddSysMenuDTO dto) {
        return Result.ok(menuService.savaMenu(dto));
    }

    @PostMapping("remove/{id}")
    @Operation(summary = "删除角色")
    public Result<String> removeMenu (@PathVariable("id") String id) {
        return Result.ok(menuService.removeById(id)?"删除成功":"删除失败");
    }

    @PostMapping("edit")
    @Operation(summary = "编辑角色")
    public Result<String> editMenu (@RequestBody EditSysMenuDTO dto) {
        return Result.ok(menuService.editMenu(dto));
    }

    @PostMapping("query")
    @Operation(summary = "角色分页查询")
    public Result<Page<SysMenuVo>> queryMenuPage (@RequestBody QueryMenuPageDTO dto) {
        return Result.ok(menuService.queryMenuPage(dto));
    }

    @PostMapping("queryInfo/{id}")
    @Operation(summary = "查询角色详情")
    public Result<SysMenuVo> queryInfo (@PathVariable("id") String id) {
        return Result.ok(menuService.queryInfo(id));
    }
}
